<extend file="resource/view/home">
	<block name="content">
		<!--****************************子类继承开始*********************************************-->
		<div id="Show_main">
			<!--top分类-->
			<div class="main_classification">
				<a href="{{u('entry.index')}}">首页</a><span>></span>
				<foreach from="$fatherData" key="$k" value="$v">
					<a href="{{u('listPage.index',['cid'=>$v['cid']])}}">{{$v['cname']}}</a><span>></span>
				</foreach>
				<span>{{$goods['gname']}}</span>
			</div>
			<div class="Show_main_synopsis">

				<div class="Show_main_left">
					<div class="jqzoom" id="product-gallery">
						<a href="{{$goods['big'][0]}}">
							<img src="{{$goods['medium'][0]}}">
						</a>
						<ul class="jqzoom-list">
							<foreach from="$goods['medium']" key="$k" value="$v">
								<li>
									<a data-small="{{$goods['medium'][$k]}}" href="{{$goods['big'][$k]}}">
										<img src="{{$goods['small'][$k]}}">
									</a>
								</li>
							</foreach>
						</ul>
					</div>
				</div>
				<!--左侧放大镜区域结束-->
				<!--右侧简介开始-->
				<div class="Show_main_right">
					<div class="Show_main_right_contentnt">
						<div class="Show_main_right_contentnt_top">

							<div class="Show_main_right_top_hl">
								<h1>{{$goods['gname']}} </h1>
								<p>——> {{$goods['describe']}}！

								</p>
							</div>
							<div class="Show_main_right_content_money">
								<div>
									<label for="">华&nbsp;为&nbsp;价:</label>
									<b>￥{{$goods['shopprice']}}</b>
								</div>
								<div>
									<label for="">商品编码:</label>

									<span>{{$goods['gnumber']}}</span>
								</div>
								<foreach from="$attrData" key="$k" value="$v">
								<div>
									<label for="">{{$v['taname']}}:</label>
									<foreach from="$v['attr']" key="$kk" value="$vv">


									<span style="color: red;font-size: 12px">
									  &nbsp;&nbsp;<b  style="font-size: 12px">{{$vv['gavalue']}}</b>
									</span>
										</foreach>
								</div>
								</foreach>
							</div>
<!--							规格-->
							<div class=" particulars">
								<dl>

								<foreach from="$specData" value="$v">
									<dt>{{$v['taname']}}&nbsp;：</dt>
									<dd>
										<foreach from="$v['spec']" value="$vv"><div class="img " taname="{{$v['taname']}}" gaid="{{$vv['gaid']}}"><a href="javascript:;" class="text " >{{$vv['gavalue']}}</a></div></foreach>
									</dd>
									</foreach>

<!--									规格Js-->
									<script>
										$(function(){
//											点击添加class

											$('.Show_main_right_contentnt_top .particulars dd .img ').click(function(){

												$(this).addClass('oncolor').siblings().removeClass('oncolor');

											})

										})
									</script>
									<script>
										$(function(){

//											判断规格是否全选

											$('.Show_main_right_contentnt_top .particulars dd .img ').click(function(){
												if($('.oncolor').length!={{count($specData)}}){

													return false;
												}

												var combine='';
												$.each($('.oncolor'),function(){

													combine  += $(this).attr('gaid') + '|';

												})
												var gid={{q('get.gid')}};
												$.post("{{u('ajaxGetTotal')}}",{gid:gid,combine:combine},function(res){
													if(res.valid){
														$('#inventory').html("库存为："+"<span num="+res.total+" style='color: red;'>"+ res.total+"</span>");
//														如果有库存让按钮可以点击
														$('.Show_main_right_contentnt_botom .car').addClass("goCar").removeClass("huise");
														$('.Show_main_right_contentnt_botom .jiesuan').removeClass("huise");
													}else{
														$('#inventory').html("库存为："+"<span style='color: red;'>"+ 0+"</span>");
//														如果没有库存让购物和结算按钮不能按
														$('.Show_main_right_contentnt_botom .car').addClass("huise").removeClass("goCar");
														$('.Show_main_right_contentnt_botom .jiesuan').addClass("huise").removeClass("goCar");
													}

												},'json');

											});
										});
									</script>

<!--									点击立即购买-->
									<script>
										$(function(){
											$('.Show_main_right_contentnt_botom .car').on('click',function(){
												if($(this).is('.huise')){
													alert('请选择商品规格');
													return ;
												}
//												判断库存与购买量-->
												var total=$('#inventory').find('span').attr('num');
												var carNum=$('.addCarNum').val();


												if(total-carNum<0){
													alert('库存不足');
													return;
												}
												var data={
													'gid':{{q('get.gid')}},
													'num':$('.addCarNum').val(),
													'options':{},
													'kucun':$('#inventory').find('span').attr('num'),

												}
												$.each($('.oncolor'),function(){
													data.options[$(this).attr('taname')]=$(this).text();
												})
												$.post("{{u('ajaxAddCart')}}",data,function(res){
													if(res==1){
														location.href='index.php'+'?s=home/mycar/index';
													}
												},'json');


											})
										})

									</script>
									<dt>关联商品：</dt>
									<dd>
										<foreach from="$hotGoods" value="$v">
											<div class="img2">
												<a href="{{u('index',['gid'=>$v['gid']])}}" class="text " > 关联商品 >> {{$v['gname']}}</a>

											</div>
										</foreach>

									</dd>
									<dt>购买数量：</dt>
									<dd>
										<div class="img2">
											<input type="number" class="addCarNum" value="1" min="1" max="999" />
										</div>

									</dd>

								</dl>


							</div>
							<!--底部参加购物-->
							<div  class="Show_main_right_contentnt_botom">
								<p id="inventory"> </p>
								<a href="javascript:;" class="huise car " ><span>加入购物车</span></a>
							</div>
						</div>


					</div>
				</div>
			</div>
			<!--推荐搭配开始-->
			<div class=" show_collocation">

				<div class=" show_collocation_h">
					<h3>
						<a href="">
							<span >
								热门推荐
							</span>
						</a>

					</h3>
				</div>
				<div class="show_collocation_content">
					<ul class="show_collocation_content_left">
						<foreach from="$hotGoods" value="$v">
						<li>
							<a href="{{u('index',['gid'=>$v['gid']])}}"><img src="{{$v['pic']}}"/></a>
							<p> 商城价￥:{{$v['shopprice']}}</p>
							<a href="{{u('index',['gid'=>$v['gid']])}}" class="text">{{$v['gname']}}{{$v['describe']}} </a>
						</li>
						</foreach>
					</ul>
				</div>
			</div>
			<!--热销榜单商品详情 用户评价大盒子-->
			<div class="show_main_layout">
				<!--左侧热销榜单和浏览过的商品-->
				<div class="show_main_layout_left">
					<!--左侧热销榜单框-->
					<div class="copy">
						<h3>
							<span>热销榜单</span>
						</h3>
						<ul>
							<foreach from="$hotXiao" value="$v">
								<li>
									<img style="height:56px;width:56px" src="{{$v['pic']}}"/>
									<p>
										<a href="{{u('show.index',['gid'=>$v['gid']])}}"> {{$v['gname']}} {{$v['describe']}}</a>
										<span> ￥{{$v['shopprice']}}</span>
									</p>
								</li>
							</foreach>
						</ul>
					</div>

				</div>
				<!--右侧商品详情用户品评价*******88-->
				<div class="show_main_layout_right">
					<!--顶部-->
					<div class="show_main_layout_right_top">
						<ul>
							<li class="border_color"><span >商品详情</span></li>
						</ul>

					</div>
					<!--内容-->
					<div class="show_main_layout_right_content">
						<ul>
							<li><img src="{{$goods['intro']}}"/></li>
							<li>
								<p>※本网站尽可能地提供准确的信息。本网站内所涉及的产品图片与实物可能有细微区别，效果演示图和示意图仅供参考（图片为合成图、模拟演示图），有关产品的外观（包括但不限于颜色）请以实物为准。</p>
								<p>※限于篇幅，本网站中所包含的信息（包括但不限于产品规格、功能说明等）可能不完整，请以有关产品使用说明书的具体信息为准。</p>
							</li>
						</ul>
					</div>
				</div>
			</div>
		</div>
	</block>
	<!--********************************************子类继承结束-*****************-->


